new Vue({
  el: "#app",
  data() {
    return {
      form: {
        Data: "company_history",
        page: 1, //页数
        limit: 10, //每页数据条数
      },
      formData: {},
      tableData: [{}], //表格数据
      total: 1,
      dialogForm: false,
      title: "",
      NewsInfo: "",
      multipleSelection: [],
    };
  },
  mounted() {
    this.getList(this.form);
  },
  methods: {
    onSerach() {
      //查询方法
      console.log("搜搜");
    },
    addContract() {
      console.log("跳转");
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form);
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form);
    },
    getList(data) {
      //换页方法
      let _this = this;
      $.ajax({
        type: "POST",
        // url: DomainName + "/getTableInquiryAction?token=" + $.cookie("token"),
        url: "https://service.kdddy.cn/donghui/generalBusiness/generalQueryByTableNameWithOriginal",
        data: {
          Data: "company_history", //表名
          Condition: "Row_Status='0'",
        },
        // complete: function (XMLHttpRequest) {
        //   _this.loading = false
        //   if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
        //     window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
        //   }
        // },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result; //将获取的数据存到表格数据中
          _this.total = Number(Result.limit);
        },
        dataType: "json",
      });
    },
    addEnterprise() {
      window.location.href = "./Add.html";
    },
    editMember(Item_SerialNumber) {
      sessionStorage.setItem("Item_SerialNumber", Item_SerialNumber);
      window.location.href =
        "./Edit.html?Item_SerialNumber=" + Item_SerialNumber;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    SeeDetail(row) {
      window.sessionStorage.setItem("News_SerialNumber", row.News_SerialNumber);
      window.location.href = "./EarfungustechnologyDetail.html";
    },
    deletMember(index, row) {
      console.log(row);
      row.Row_Status = "1";
      let lArray = new Array();
      lArray.push(row);
      let lJSONObject_company_history = new Object();
      lJSONObject_company_history.company_history = lArray; //换表
      let lJSONObject_DataSet = new Object(); // Modify
      lJSONObject_DataSet.Modify = lJSONObject_company_history; //换表
      const _this = this;
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });

          $.ajax({
            // headers: requestHeaders(),
            // url: `${BASE_URL2}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
            url: "https://service.kdddy.cn/donghui/clientOperation/generalSaveForClient",
            type: "POST",
            data: {
              Data: JSON.stringify(lJSONObject_DataSet),
            },
            success: function (Result) {
              console.log(Result);
              if (Result.Status === "success") {
                _this.tableData.splice(index, 1);
              } else {
                _this.$message.error("提交失败，请稍后再试");
              }
            },
            // complete: function (XMLHttpRequest) {
            //   requestPretreatment(XMLHttpRequest); //config/config.js 响应预检
            // },
            dataType: "json",
          });
        })
        .catch(() => {
          _this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      return;
      this.$confirm("此操作将删除该发展信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      }).then(() => {
        row.Row_Status = "1";
      });
    },
    getOriginal(data) {
      const _this = this;
      $.ajax({
        url: DomainName + "/getInquiryIDOriginal?token=" + $.cookie("token"),
        type: "POST",
        data,
        success: function (res) {
          console.log(res);
          res[0].Row_Status = "3";
          res[0].News_Date = getYMDHMSDate();
          let Data = {
            Data: JSON.stringify({
              Modify: { news_info: [res[0]] },
            }),
          };
          _this.Delete(Data);
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false;
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href =
              "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
      });
    },
    Delete(data) {
      this.loading = true;
      const _this = this;
      $.ajax({
        url: DomainName + "/getEditAction?token=" + $.cookie("token"),
        type: "POST",
        data,
        success: function (res) {
          console.log(res);
          if (res.Status == "success") {
            _this.$message({
              type: "success",
              message: "已删除!",
            });
            _this.loading = false;
            _this.getList(_this.form);
          }
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false;
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href =
              "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
      });
    },
  },
});
